package com.java.ssm.service.impl;

import com.java.ssm.dao.DictionariesDao;
import com.java.ssm.entity.Dictionaries;
import com.java.ssm.service.DictionariesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Dictionaries)表服务实现类
 *
 * @author makejava
 * @since 2021-01-21 08:42:16
 */
@Service("dictionariesService")
public class DictionariesServiceImpl implements DictionariesService {
    @Resource
    private DictionariesDao dictionariesDao;

    /**
     * 通过ID查询单条数据
     *
     * @param dId 主键
     * @return 实例对象
     */
    @Override
    public Dictionaries queryById(Integer dId) {
        return this.dictionariesDao.queryById(dId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Dictionaries> queryAllByLimit(int offset, int limit) {
        return this.dictionariesDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param dictionaries 实例对象
     * @return 实例对象
     */
    @Override
    public Dictionaries insert(Dictionaries dictionaries) {
        this.dictionariesDao.insert(dictionaries);
        return dictionaries;
    }

    /**
     * 修改数据
     *
     * @param dictionaries 实例对象
     * @return 实例对象
     */
    @Override
    public Dictionaries update(Dictionaries dictionaries) {
        this.dictionariesDao.update(dictionaries);
        return this.queryById(dictionaries.getDId());
    }

    /**
     * 通过主键删除数据
     *
     * @param dId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer dId) {
        return this.dictionariesDao.deleteById(dId) > 0;
    }
}